********Table F.1 - Indonesia********

*Load data
cd "$reploc/data/created_data"
use indo_full, clear

*Do these results for primary sample
sort pidlink ifls
foreach var of varlist rbuc_garefined rbuc grbrprovAvg_lam0co3 grbrprovSD_lam0co3 inflation{
gen `var'dif=`var'-`var'[_n-1] if ifls==5 & pidlink==pidlink[_n-1]
} 

egen coh_prov_clust=group(biryear_impl birprov_impl)

gen primarysample1=0
replace primarysample1=1 if rbuc_garefineddif!=. & grbrprovAvg_lam0co3dif!=. & grbrprovSD_lam0co3dif!=. & inflationdif!=. &  biryear_impl>=1961 & coh_prov_clust!=.

egen primarysample=total(primarysample1), by(pidlink)

keep if primarysample==1

*Normalize
gen assets_ia_use=assets_ia/1000000
gen income_ia_use=income_ia/1000000
gen aggexpcons_ia_use=aggexpcons_ia/1000000
gen saving_ia_use=savingtotal/1000000
gen borrowing_ia_use=borrowingtotal_ia/1000000


*Generate location
gen loc=.
replace loc=Prov2007 if ifls==4
replace loc=Prov2014 if ifls==5

quietly tab ifls, gen(Idum)

*Regression

local regvars entrep evermig income_ia_use assets_ia_use saving_ia_use borrowing_ia_use aggexpcons_ia_use smoke smoketot woman imp_age imp_age_sq 
local controls  Idum2 married Eddum* i.religiosity i.loc hhsize 

local x rbuc 

reg `x' `regvars' `controls', robust cluster(coh_prov_clust)

cd "$reploc/results"
outreg2 using TableF1_Indonesia.tex, replace label keep(`regvars') dec(2) sdec(2)




